require(["common", "jQuery", "coAjax", "queryString", "href", "hash_routie"], function(jSouper, $, coAjax, QueryString, href, hash_routie) {
	_init_express();
	hash_routie.on("express", function() {
		coAjax.get(appConfig.bus.express_list, function(result) {
			App.set("$Cache.bus.express.list", result.result)
		});
	});
	//增加
	App.set("$Event.bus.express.add_express", function(e, vm) {
		coAjax.post(appConfig.bus.express_add, App.get("$Cache.bus.express.new"), function(result) {
			var express_list = App.get("$Cache.bus.express.list");
			express_list.unshift(result.result);
			App.set("$Cache.bus.express.list", express_list)
			alert("success", "增加成功")
		});
	});
	//修改
	App.set("$Event.bus.express.update_express", function(e, vm) {
		coAjax.put(appConfig.bus.express_update + App.get("$Cache.bus.express.new._id") + "?return_type=list", App.get("$Cache.bus.express.new"), function(result) {
			App.set("$Cache.bus.express.list", result.result);
			alert("success", "修改成功")
		});
		App.get("$Event.bus.express.cancel")();
	});
	//删除
	App.set("$Event.bus.express.remove_express", function(e, vm) {
		coAjax["delete"](appConfig.bus.express_remove + vm.get("_id"), function(result) {
			App.set("$Cache.bus.express.list", result.result)
			alert("success", "删除成功")
		});
	});
	//编辑指定表单
	App.set("$Event.bus.express.to_update", function(e, vm) {
		App.set("$Cache.bus.express.new", vm.get());
	});
	//重置编辑中的表单
	App.set("$Event.bus.express.cancel", function(e, vm) {
		App.set("$Cache.bus.express.new", {});
	});

	//修还运费减免配置
	App.set("$Event.bus.express.update_express_free", function() {
		coAjax.put(appConfig.bus.set_info_url, App.get("bus_loginer.info"), function(result) {
			// console.log(result);
			alert("success", "修改完成");
			App.set("bus_loginer", result.result)
		});
	})
});